package com.example.Rim.View;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.view.View;
import android.widget.*;
import android.widget.AdapterView.OnItemSelectedListener;
import com.example.Rim.R;

/**
 * Created by hulu on 2014/11/25.
 */
public class ActivityMenu extends Activity {

    private static final String[] s={"范围：1000m内","范围：2000m内","范围：3000m内","范围：4000m内","范围：5000m内","千里之外"};
    private Spinner spinner;
    private ArrayAdapter<String> adapter;

    private Button menusecondButton;
    private Button refreshButton;
    private Button changeButton;
    private String list_text;
    private TextView menuTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_menu);

        menuTextView = (TextView) findViewById(R.id.menuTextView);

        Intent intent = getIntent();
        list_text = intent.getStringExtra("list_text");
        menuTextView.setText(list_text);

        spinner = (Spinner) findViewById(R.id.Spinner);
        //将可选内容与ArrayAdapter连接起来

        menusecondButton = (Button) findViewById(R.id.menusecondButton);
        menusecondButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });

        refreshButton = (Button) findViewById(R.id.refreshButton);
        refreshButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        changeButton = (Button) findViewById(R.id.changeButton);
        changeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });

        adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,s);

        //设置下拉列表的风格
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        //将adapter 添加到spinner中
        spinner.setAdapter(adapter);

        //添加事件Spinner事件监听
//        spinner.setOnItemSelectedListener(new SpinnerSelectedListener());

        //设置默认值
        spinner.setVisibility(View.VISIBLE);

    }

    //使用数组形式操作
//    class SpinnerSelectedListener implements OnItemSelectedListener{
//
//        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
//                                   long arg3) {
//            view.setText("选择的范围是："+s[arg2]);
//        }
//        public void onNothingSelected(AdapterView<?> arg0) {
//        }
//    }
}
